
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.ArrayList,
                 com.scalar.chiptrack.utils.ConfigManager,
                 com.scalar.chiptrack.users.Functionality,
                 com.scalar.chiptrack.users.User,
                 com.scalar.chiptrack.utils.StringUtils,
                 com.scalar.chiptrack.sales.RepOffice,
                 com.scalar.chiptrack.sales.dao.CustomerDAO"%>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/addNewRepOffice.do"/>

<html:html locale="true">

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>

<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js">
</script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js">
</script>
<script language='javascript'>
function save()
{
    var errors = '';
    var repoffice = document.addNewRepOfficeForm.newRepOffice.value;
    if( repoffice.value != '')
    {
            if( repoffice.trim().length == 0)
            {
                errors = errors + "<li> Please enter Regional Rep name";
            }
    }
    if(errors != '')
    {
        var inf = document.getElementById("infoMessagesId");
        inf.innerHTML = '';
        var err = document.getElementById("errorMessagesId");
        err.innerHTML = '';

        var pa=document.getElementById("errors");
        pa.innerHTML = errors;
        return;
    }

   var customerId = window.opener.document.customerForm['customer.customerId'].value;
  // alert(customerId);
   document.addNewRepOfficeForm.action = '<%=chipTracContext%>/addNewRepOffice.do?action=insertRepOffice&customerId=' + customerId;

    document.addNewRepOfficeForm.submit();
}
function reset(){
    document.addNewRepOfficeForm.reset();
}
function closeWindow(form) {
    window.opener.document.customerForm['customer.customerNumber'].disabled=false;
    window.opener.document.customerForm.submit();
 	window.close();
}


</script>

<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor='#ffffff' leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">

<!-- from here your body starts -->

<html:form name="addNewRepOfficeForm" type="com.scalar.chiptrack.sales.forms.AddNewRepOfficeForm" action="/addNewRepOffice.do?action=insertRepOffice" scope="request">


<center><span class="NArialW">Regional Rep</span></center>
<img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20>
<table border="0" width="90%" align=right>
 <tr><td>
 <table border="0" width="100%" cellspacing='10' cellpadding='2' align='left'>
 <tr><td colspan=2 align=RIGHT><a href="javascript:closeWindow(document.addNewRepOfficeForm);" onMouseOver="window.status='Click here to close this window';return true" onmouseout="window.status='';return true" ><font class='NArialL'>Close this window</font></a></td></tr>
   <tr><td colspan=2 id='errorMessagesId'><chiptrack:errors styleClass='NArialL' /></td></tr>
    <tr><td colspan=2 id='infoMessagesId'><chiptrack:info styleClass='NArialL' /></td></tr>

    <!--tr><td colspan='2'><img src="<%=chipTracContext%>/jsp/includes/images/spacer/gif" height=10></td></tr-->
    <tr><td colspan='2' align="left" class='NArialL'><FONT id="errors" styleClass="NArialL" color='FF0000'></FONT></TD></TR>
	<tr>
        <td colspan='2' nowrap><font class="NArialL">New Regional Rep:<font color=red>*</font>&nbsp;&nbsp;</font>
			<html:text property="newRepOffice" size="25" maxlength="25" styleClass="txfield"/>
		</td>

    </tr>

	<tr>
        <td colspan='1' nowrap align='center'>
		     <a href="javascript:save()" onMouseOver="window.status='Click to Add Regional Rep';return true" onmouseout="window.status='';return true" title="Click here to Add Regional Rep"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" width="53" height="17"></a>
	    </td>
		<td colspan='1' nowrap align='left'>
		     <a href="javascript:reset()" onMouseOver="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17"></a>
	    </td>
    </tr>

  </table>

  </td></tr>
  <!--tr><td><img height=10 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td></tr-->
  <tr><td>

<!-- DISPLAY ALL USERS STARTS HERE -->

<% ArrayList repOffices = (ArrayList) request.getAttribute("repOffices");
	if( repOffices != null && repOffices.size() != 0 ) { %>

   <table border="0" width="100%" bordercolor="#FFFFFF" align=right>
    <tr>
        <td width="15%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Regional Rep</font></font></td>
        <td width="15%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Action</font></font></td>
        <td width="15%">&nbsp;</td>
    </tr>

    <% int bgcount = 0;%>
    <logic:iterate id="RepOffice" name="repOffices" type="com.scalar.chiptrack.sales.RepOffice">
    <% bgcount = bgcount + 1; %>
    <tr>
    <td nowrap width="15%" align="left" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL">
    <bean:write name="RepOffice" property="repOffice" /></font></td>
    <html:hidden name="RepOffice" property="repOffice" />
     <td nowrap width="15%" align="left" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL">
     <logic:equal name="RepOffice" property="disabled" value="true">
     <a href='<%=chipTracContext%>/addNewRepOffice.do?repofficestatus=disable&repoffice=<bean:write name="RepOffice" property="encodeRepOffice" />&customerId=<%=request.getParameter("customerId")%>' onMouseOver="window.status='Click to Disable Regional Rep';return true" onmouseout="window.status='';return true" >Disable</a>
     </logic:equal>
     <logic:equal name="RepOffice" property="disabled" value="false">
     <a href='<%=chipTracContext%>/addNewRepOffice.do?repofficestatus=activate&repoffice=<bean:write name="RepOffice" property="encodeRepOffice" />&customerId=<%=request.getParameter("customerId")%>' onMouseOver="window.status='Click to Activate Regional Rep';return true" onmouseout="window.status='';return true"><font color='red'> Activate</font></a>
     </logic:equal>
     </font></td>

    </tr>
    </logic:iterate>

    <tr><td class="NArialL" colspan=5><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=50></td></tr>
    <tr><td colspan=3 align=center><a href="javascript:closeWindow(document.addNewRepOfficeForm);" onMouseOver="window.status='Click here to close this window';return true" onmouseout="window.status='';return true"><font class='NArialL'>Close this window</font></a></td></tr>

    </table>
	<% } %>

<!-- DISPLAY ALL USERS ENDS HERE -->

</td></tr>
</table>
<input type="hidden" name="customerId" value ='<%=request.getParameter("customerId")%>' >

</html:form>


</body>

</html:html>